import axios from "./index";
import type { Ref } from "vue";
//登录
export function longin(data:iuser) {
    return axios.post("/user/login", data);
  }

  //添加地址
  export function address(data:address) {
    return axios.post("/address/add", data);
  }
  //获取地址列表
  export function getress(data:getgoodslist) {
    return axios.get(`/address/list?userid=${data.userid}`);
  }
  //修改地址
  export function setupdate(data:setupdate){
    return axios.post("/address/update",data)
  }
  //查询默认地址
  export function setmordiz(data:getgoodslist){
    return axios.post('/address/defaultAddress',data)
  }
  //删除
  export function setdelete(data:setdelete){
    return axios.post("/address/delete",data)
  }
  //获取购物车数据
  export function getgoodslist(data:getgoodslist) {
    return axios.post("/cart/list", data);
  }
  //获取推荐列表
  export function gettjlist() {
    return axios.get("/pro/recommendlist");
  }
  //获取产品详情
  export function getdetail(data:getdetail) {
    return axios.get(`/pro/detail/${data.proid}`,{
      params:{
          proid:data.proid,
      }
    });
  }
  //添加购物车
  export function setaddcar(data:setaddcar){
      return axios.post("/cart/add",data)
  }
  //删除购物车单条
  export function removecar(data:removecar){
    return axios.post("/cart/remove",data)
  }
  //更新购物车数量
  
  export function updatenum(data:updatenum){
      return axios.post("/cart/updatenum",data)
  }
  //更改单条购物车选中状态
  export function selectone(data:selectone){
      return axios.post("/cart/selectone",data)
  }
  //更改全部购物车选中状态
  export function selectall(data:selectall){
      return axios.post("/cart/selectall",data)
  }
  //清空购物车
  export function removecarall(data:getgoodslist){
    return axios.post("/cart/removeall",data)
  }
  //获取热门商品
  export function gethotword(){
      return axios.get("/pro/hotword")
  }
  //搜索列表
  export function getsearch(data:getsearch){
      return axios.get("/pro/search",{
        params:{
         data
        }
      })
  }
  //搜索详情
  export function getseldel(count:Ref<any>,keyword:Ref<any>){
    return axios.get(`/pro/search?count=${count}&keyword=${keyword}`)
  }